const { getActiveStr } = require("../../../utils/utilsNew");

// component/common/com-pick-house-item/com-pick-house-item.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    model: {
      type: Object,
      value: {},
    },
  },

  options: {
    styleIsolation: "apply-shared",
    addGlobalClass: true,
  },

  /**
   * 组件的初始数据
   */
  data: {
    _model: {},
  },

  lifetimes: {
    attached: function () {
      let model = this.data.model;
      let result = { ...model };
      result.title = getActiveStr(result.title, 24);
      result.total_prices =
        result.total_prices && result.total_prices != -1 && result.total_prices != -0.01
          ? result.delegation_type == "SALES"
            ? result.total_prices / 10000 + "万元"
            : result.total_prices + "元/月"
          : "未填价格";
      result.room = result.room ? result.room + "室" : "";
      result.hall = result.hall ? result.hall + "厅" : "";
      result.room_hall = result.room + result.hall;
      result.room_hall = result.room_hall ? result.room_hall : "未填户型";
      result.build_size = result.build_size != -1 && result.build_size ? result.build_size + "㎡" : "未填面积";
      result.img_id = result.img_id || "/images/defaultImgSmall.jpg";
      result.area = result.area || ""
      result.addr = result.addr || ""
      result.area_addr = (!result.area && !result.addr) ? '暂无地址' : result.area + " " +result.addr;

      this.setData({
        _model: result,
      });
    },
    
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {},
});
